<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var isValid = function (s) {
      const stk = [];
      for (let i = 0; i < s.length; i++) {
        const c = s[i];
        stk.push(c);// slice 提取字符串的片断 
        if (stk.length >= 3 && stk.slice(stk.length - 3).join("") === "abc") {
          stk.splice(stk.length - 3, 3);
        }
      }
      return stk.length === 0;
    };
    console.log(isValid("aabcbc"))
  </script>
</body>

</html>